using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace GraphicsLib
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        Graphics2D myGraphicsLib;
        Texture2D myNoiseTexture;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {
            var basicTexture = Content.Load<Texture2D>("whitepx");
            myNoiseTexture = Content.Load<Texture2D>("noise");
            spriteBatch = new SpriteBatch(GraphicsDevice);
            myGraphicsLib = new Graphics2D(spriteBatch, basicTexture);
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(new Color(0.1f, 0.1f, 0.1f));
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);

            // lines
            myGraphicsLib.DrawLineBetweenPoints(new Vector2(10, 10), new Vector2(100, 100), Color.Green, 4);
            myGraphicsLib.DrawLineBetweenPoints(new Vector2(250, 250), new Vector2(500, 300), Color.Goldenrod, 8);

            // rectangles            
            myGraphicsLib.DrawRectangle(150, 150, 100, 50, Color.Red);
            myGraphicsLib.DrawRectangle(175, 175, 100, 50, new Color(Color.Blue, 0.5f));
            myGraphicsLib.DrawBorderedRectangle(
                new Rectangle(400, 150, 150, 30), 
                5, 
                Color.White, 
                Color.Red,
                Graphics2D.eBorderType.External);

            myGraphicsLib.DrawBorderedRectangle(
                new Rectangle(400, 50, 150, 30),
                5,
                Color.White,
                Color.Red,
                Graphics2D.eBorderType.Internal);

            // laser line
            myGraphicsLib.DrawLaserLineBetweenPoints(
                new Vector2(100, 500),
                new Vector2(500, 500),
                myNoiseTexture,
                Color.Red,
                2);

            // outline shapes
            myGraphicsLib.DrawRectangleOutline(100, 350, 200, 100, 5, Color.LightBlue);
            myGraphicsLib.DrawRectangleOutline(120, 370, 160, 60, 5, Color.Blue);
            myGraphicsLib.DrawRectangleOutline(140, 390, 120, 20, 5, Color.DarkBlue);

            spriteBatch.End();
            base.Draw(gameTime);
        }
    }
}
